package de.LooLo;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * @author Kevin Seppelt
 * Adapter for additional Loo Information in Detail View
 * 
 */
public class CvDetailElementAdapter extends BaseAdapter{

	private List<CvDetailElement> list ;
	private Context context;
	
	@SuppressWarnings("unused")
	private Toilet loo;
	private ArrayList<String> items = new ArrayList<String>();
	
	private TextView description;
	private TextView value;
	
	
	public CvDetailElementAdapter(Context context,List<CvDetailElement> list, Toilet loo, ArrayList<String> items) {
		this.list = list;
		this.context = context;
		this.loo = loo;
		this.items = items;
	}
	
	public int getCount(){
		if (list != null) return  list.size();
		else return 0;
	}

	public CvDetailElement getItem(int arg0) {
		return list.get(arg0);
	}
	
	public long getItemId(int arg0) {
		if(list.get(arg0)!=null)return list.get(arg0).getId();
		return 0;
	}

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
	 */
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		
		if (arg1 == null) {
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			arg1 = inflater.inflate(R.layout.cv_paper,null);
		} 
		
		CvDetailElement cve = list.get(arg0);
		
		if(cve!=null){
			
			description = (TextView) arg1.findViewById(R.id.cv_paper_description);
			value   	= (TextView) arg1.findViewById(R.id.cv_paper_value);
			
			description.setText(items.get(arg0*2));
			value.setText(items.get((arg0*2)+1));
			
		}		
		
		
		return arg1;
	}

}
